package com.example.datasource.service;

import com.example.datasource.annotation.MyDataSource;
import com.example.datasource.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description :
 * @Author : Bruce Lee
 * @CreateTime : 2024/4/17
 */

@Service
public class DataService {

    @Autowired
    private UserMapper userMapper;

//    @MyDataSource("master")
    @MyDataSource("slaver")
    public void test()
    {
        userMapper.insertUser("aop", "aop");
        System.out.println("动态数据源切换成功！");
    }
}
